﻿using Kimd.Motion;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WorkStation.Logic
{
    public class Holder : Tray
    {
        /// <summary>
        /// 假镜头状态
        /// </summary>
        public List<bool> MirrorStatus { get; set; }
        public List<string> MirrorSN { get; set; }
        /// <summary>
        /// Holder编号
        /// </summary>
        public string HolderNo { get; set; }
        public Holder(string name, int row, int col, string holderNo)
            : base(row, col)
        {
            this.Name = name;
            this.MirrorStatus = new List<bool>() { false, false, false, false };
            this.HolderNo = holderNo;
            this.MirrorSN = new List<string>();
        }
        public void EmptyMirror()
        {
            MirrorStatus.ForEach(x => x = false);   
        }
        public bool IsMirrorEnough()
        {
            int count = MirrorStatus.Sum(x => x ? 1 : 0);
            return count >= 2;
        }
        public bool IsMirrorFull()
        {
            int count = MirrorStatus.Sum(x => x ? 1 : 0);
            return count >= 4;
        }
        public void CopyTo(Holder holder)
        {
            holder.MirrorSN = new List<string>();
            for (int i = 0; i < MirrorStatus.Count; i++)
            {
                holder.MirrorStatus[i] = this.MirrorStatus[i];
                holder.MirrorSN.Add(this.MirrorSN[i]);
            }
            holder.HolderNo = this.HolderNo;
            for (int i = 0; i < RowCount; i++)
            {
                for (int j = 0; j < ColCount; j++)
                {
                    holder.Helper.GetCell(i, j).Result = this.Helper.GetCell(i, j).Result;
                    holder.Helper.GetCell(i, j).Status = this.Helper.GetCell(i, j).Status;
                    holder.Helper.GetCell(i, j).SN = this.Helper.GetCell(i, j).SN;
                    holder.Helper.GetCell(i, j).MirrorNo = this.Helper.GetCell(i, j).MirrorNo;
                    holder.Helper.GetCell(i, j).CellStationNo = this.Helper.GetCell(i, j).CellStationNo;
                    holder.Helper.GetCell(i, j).IsTestFinish = this.Helper.GetCell(i, j).IsTestFinish;
                }
            }
        }
    }
}
